package com.moon.game.vos;

import java.util.Map;

import com.moon.game.constants.GBaseObject;

/**
 * 错误信息
 * 
 * @author Ranger
 * 
 */
public class ErrorMsg extends GBaseObject {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1408309684480819304L;
	private int code;
    private String msg;
    private Map<String, Object> datas;

    private ErrorMsg(int code, String msg, Map<String, Object> datas) {
        this.code = code;
        this.msg = msg;
        this.datas = datas;
    }

    private ErrorMsg(int code, Map<String, Object> datas) {
        this(code, null, datas);
    }

    private ErrorMsg(int code, String msg) {
        this(code, msg, null);
    }

    private ErrorMsg(int code) {
        this(code, null, null);
    }

    /**
     * @return the code
     */
    public final int getCode() {
        return code;
    }

    /**
     * @param code
     *            the code to set
     */
    public final void setCode(int code) {
        this.code = code;
    }

    /**
     * @return the msg
     */
    public final String getMsg() {
        return msg;
    }

    /**
     * @param msg
     *            the msg to set
     */
    public final void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * @return the datas
     */
    public final Map<String, Object> getDatas() {
        return datas;
    }

    /**
     * @param datas
     *            the datas to set
     */
    public final void setDatas(Map<String, Object> datas) {
        this.datas = datas;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "ErrorMsg [code=" + code + ", msg=" + msg + "]";
    }

    /**
     * 错误消息构建
     * 
     * @param errorCode
     * @param errorMsg
     * @param obj
     * @return
     */
    public static ErrorMsg build(int errorCode, String errorMsg, Map<String, Object> datas) {
        return new ErrorMsg(errorCode, errorMsg, datas);
    }

    public static ErrorMsg build(int errorCode, Map<String, Object> datas) {
        return new ErrorMsg(errorCode, datas);
    }

    public static ErrorMsg build(int errorCode, String errorMsg) {
        return new ErrorMsg(errorCode, errorMsg);
    }

    public static ErrorMsg build(int errorCode) {
        return new ErrorMsg(errorCode);
    }
}
